package com.example.strategy.service.impl;

import com.example.strategy.factory.PayStrategyFactory;
import com.example.strategy.service.PayService;
import com.example.strategy.service.PayStrategy;
import org.springframework.stereotype.Service;

/**
 * @author xwj
 * @date 2021/4/28 17:23
 * description:
 */
@Service("payService")
public class PayServiceImpl implements PayService {

    @Override
    public String pay(String channel, String amount) throws Exception {
        PayStrategy payStrategy = PayStrategyFactory.getPayStrategy(channel);
        if (null == payStrategy) {
            return "渠道输入有误";
        }
        return payStrategy.pay(channel, amount);

    }
}
